home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK2.toast / Development Kits (Disc 2) / QuickTime™ VR 2.0 SDK / QTVR C⁄C++ Runtime API / Sample Code / VRShell Sample Code / VR3DObjects / Application Files / MacApplication.c < prev    next >
Encoding:
Text File  |  1997-05-22  |  18.4 KB  |  716 lines  |  [TEXT/MPCC]

  1. //
  2. //    File:        MacApplication.c
  3. //
  4. //    Contains:    QuickDraw 3D support for QuickTime VR movies.
  5. //
  6. //    Written by:    Tim Monroe
  7. //                Based (heavily!) on the MovieShell code written by Apple DTS
  8. //
  9. //    Copyright:    © 1994-1996 by Apple Computer, Inc., all rights reserved.
  10. //
  11. //    Change History (most recent first):
  12. //
  13. //       <11>         01/17/97    rtm        worked on InitApplicationWindowObject
  14. //       <10>         01/14/97    rtm        added static texture support
  15. //       <9>         01/13/97    rtm        added menu cases for stopping/starting sound on embedded movies
  16. //       <8>         01/12/97    rtm        added ApplicationMCActionFilterProc to consolidate mc action handling
  17. //       <7>         01/09/97    rtm        added initial FOV reset in InitApplicationWindowObject;
  18. //                                    moved rendering code into prescreen procedure
  19. //       <6>         01/06/97    rtm        DoIdle now renders and updates only when necessary;
  20. //                                    updates cursor only for front window
  21. //       <5>         12/17/96    rtm        added testing for QuickDraw 3D in appropriate places
  22. //       <4>         12/13/96    rtm        added 3D object support (see TestFunctions.c)
  23. //       <3>         12/02/96    rtm        added cursor updating to DoIdle
  24. //       <2>         11/27/96    rtm        conversion to personal coding style;
  25. //                                    added preliminary QTVR support
  26. //       <1>         12/21/94    khs        first file
  27. //       
  28. //
  29. // TODO:
  30. // + rethink DoIdle calling QTVRUpdate every null event
  31.  
  32. // header files
  33. #include "MacApplication.h"
  34. #include "MacFramework.h"
  35. #include "AppConfiguration.h"
  36. #include "DTSQTUtilities.h"
  37. #include "QTVRUtilities.h"
  38. #include <Resources.h>
  39.  
  40. // header file for the specific test functions.
  41. #include "TestFunctions.h"
  42.  
  43. // global variables
  44. long            gMaxMilliSecToUse = kMaxMilliSecToUse;
  45. Boolean            gQTVRMgrIsPresent = false;    // is the QuickTime VR Manager available?        
  46. Boolean            gHasQuickDraw3D = false;    // is QuickDraw 3D available?
  47.  
  48.  
  49. //////////
  50. //
  51. // InitApplication
  52. // Do any application-specific initialization.
  53. //
  54. //////////
  55.  
  56. void InitApplication (void)
  57. {    
  58.     // make sure that the QTVR Manager is present in the present operating environment
  59.     if (QTVRUtils_IsQTVRMgrInstalled()) {
  60.         gQTVRMgrIsPresent = true;
  61.     } else {
  62.         ShowWarning("\pThe QuickTime VR Manager cannot be found.", 0);
  63.         ExitToShell();
  64.     }
  65.  
  66.     // initialize 3D object capabilities
  67.     VR3DObjects_Init();
  68. }
  69.  
  70.  
  71. //////////
  72. //
  73. // StopApplication
  74. // Do any application-specific shutdown.
  75. //
  76. //////////
  77.  
  78. void StopApplication (void)
  79. {    
  80.     // shut down 3D object capabilities, if enabled
  81.     VR3DObjects_Stop();
  82. }
  83.  
  84.  
  85. //////////
  86. //
  87. // DoIdle
  88. // Do any processing that can/should occur at idle time.
  89. //
  90. //////////
  91.  
  92. void DoIdle (WindowRef theWindow)
  93. {
  94.     GrafPtr             mySavedPort;
  95.     WindowObject         myWindowObject;
  96.     MovieController        myMC = NULL;
  97.     Point                myPoint;
  98.     
  99.     GetPort(&mySavedPort);
  100.     SetPort(theWindow);
  101.     
  102.     myWindowObject = (WindowObject)GetWRefCon(theWindow);
  103.     if (myWindowObject != NULL) {
  104.     
  105.         myMC = (**myWindowObject).fController;
  106.         if (myMC != NULL) {
  107.         
  108.             MoviesTask(MCGetMovie(myMC), gMaxMilliSecToUse);
  109.  
  110.             // restore the cursor to the arrow if it's outside the front movie window
  111.             // and the mouse button isn't still down;
  112.             // this is needed only for VR movies, but should probably always be done
  113.             if (theWindow == FrontWindow()) {
  114.                 GetMouse(&myPoint);
  115.                 if (!PtInMovie(MCGetMovie(myMC), myPoint) && !StillDown())
  116.                     InitCursor();
  117.             }
  118.         }
  119.     }
  120.  
  121.     // @@@INSERT ANY OTHER IDLE-BASED FUNCTIONALITY HERE
  122.     
  123.     // 3D object overlay (and QuickTime movies) support
  124.     if (myWindowObject != NULL) {
  125.         if (gHasQuickDraw3D) {
  126.             QTVRInstance            myInstance;
  127.             
  128.             myInstance = (**myWindowObject).fInstance;
  129.             if (myInstance != NULL) {
  130.                 if (QTVRGetNodeType(myInstance, kQTVRCurrentNode) == kQTVRPanoramaType) {
  131.                     QTVRUpdate(myInstance, kQTVRCurrentMode);
  132.                 } else {
  133.                     //VR3DObjects_PrescreenRoutine(myInstance, myWindowObject);
  134.                 }
  135.             }
  136.         }
  137.     }
  138.             
  139.     SetPort(mySavedPort);
  140. }
  141.  
  142.  
  143. //////////
  144. //
  145. // DoUpdateWindow
  146. // Update the specified window.
  147. //
  148. //////////
  149.  
  150. void DoUpdateWindow (WindowRef theWindow, Rect *theRefreshArea)
  151. {
  152.     GrafPtr             mySavedPort;
  153.     
  154.     if (theWindow != NULL) {
  155.         
  156.         GetPort(&mySavedPort);
  157.         SetPort(theWindow);
  158.         
  159.         BeginUpdate(theWindow);
  160.  
  161.         EraseRect(theRefreshArea);        // this is important for non-rectangular movies
  162.         
  163.         // @@@INSERT WINDOW-SPECIFIC DRAWING FUNCTIONALITY HERE
  164.         
  165.         EndUpdate(theWindow);
  166.         SetPort(mySavedPort);
  167.     }
  168. }
  169.  
  170.  
  171. //////////
  172. //
  173. // HandleContentClick
  174. // Handle mouse button clicks in the specified window.
  175. //
  176. //////////
  177.  
  178. void HandleContentClick (WindowRef theWindow, EventRecord *theEvent)
  179. {
  180. #pragma unused(theEvent)
  181.  
  182.     GrafPtr             mySavedPort;
  183.     
  184.     GetPort(&mySavedPort);
  185.     SetPort(theWindow);
  186.  
  187.     // @@@INSERT APPLICATION-SPECIFIC CONTENT CLICKING FUNCTIONALITY HERE
  188.  
  189.     SetPort(mySavedPort);
  190. }
  191.  
  192.  
  193. //////////
  194. //
  195. // HandleQTVRKeyPress
  196. // Handle QuickTime VR-specific key presses.
  197. // Returns true if the key press was handled, false otherwise.
  198. //
  199. //////////
  200.  
  201. Boolean HandleQTVRKeyPress (EventRecord *theEvent)
  202. {
  203.     Boolean        isHandled = true;
  204.     char        myCharCode;
  205.     
  206.     myCharCode = theEvent->message & charCodeMask;
  207.  
  208.     switch (myCharCode) {
  209.     
  210.         default:
  211.             isHandled = false;
  212.             break;
  213.     }
  214.  
  215.     return(isHandled);
  216. }
  217.  
  218.  
  219. //////////
  220. //
  221. // CreateMovieWindow
  222. // Create a window to display a movie in.
  223. //
  224. //////////
  225.  
  226. WindowRef CreateMovieWindow (Rect *theRect, Str255 theTitle)
  227. {
  228.     WindowRef            myWindow;
  229.         
  230.     myWindow = NewCWindow(NULL, theRect, theTitle, false, noGrowDocProc, (WindowPtr)-1L, true, 0);
  231.     return(myWindow);
  232. }
  233.  
  234.  
  235. //////////
  236. //
  237. // HandleApplicationMenu
  238. // Handle selections in the application's menus.
  239. //
  240. //////////
  241.  
  242. void HandleApplicationMenu (short theMenuID, short theMenuItem)
  243. {
  244.     MovieController     myMC = NULL;
  245.     ApplicationDataHdl    myAppData;
  246.     
  247.     myAppData = (ApplicationDataHdl)GetAppDataFromFrontWindow();    
  248.     if (myAppData == NULL)
  249.         return;
  250.                     
  251.     switch (theMenuID) {
  252.         case mTesting:
  253.             switch(theMenuItem) {
  254.                 case iTest1:    // load new picture texture
  255.                 case iTest2:    // load new movie texture
  256.                     // delete the existing texture structure, since we'll soon create another one    
  257.                     if ((**myAppData).fTexture != NULL) {
  258.                         VR3DTexture_Delete((**myAppData).fTexture);
  259.                         (**myAppData).fTexture = NULL;
  260.                     }
  261.                         
  262.                     (**myAppData).fTextureIsMovie = (theMenuItem == iTest2);
  263.                     (**myAppData).fTexture = VR3DTexture_New(theMenuItem == iTest2);
  264.                     
  265.                     if ((**myAppData).fTexture != NULL)
  266.                         VR3DTexture_AddToGroup((**myAppData).fTexture, (**myAppData).fModel);
  267.                                         
  268.                     // show the volume control button, if a sound track exists in the QT movie
  269.                     (**myAppData).fQTMovieHasSound = false;
  270.                     if ((**myAppData).fTexture != NULL) {
  271.                         if ((**(**myAppData).fTexture).fMovie) {
  272.                             if (QTUMediaTypeInTrack((**(**myAppData).fTexture).fMovie, SoundMediaType)) {
  273.                                 (**myAppData).fQTMovieHasSound = true;
  274.                                 myMC = GetMCFromFrontWindow();
  275.                                 if (myMC != NULL) {
  276.                                     QTVRUtils_ShowControllerButton(myMC, kQTVRSpeakerButton);
  277.                                 }
  278.                             }
  279.                         }
  280.                     }
  281.                     break;
  282.                 
  283.                 case iTest3:    // toggle object animation                    
  284.                     (**myAppData).fObjectIsAnimated = !(**myAppData).fObjectIsAnimated;
  285.                     break;
  286.                 
  287.                 case iTest4:    // stop embedded movie sound                    
  288.                     if ((**myAppData).fTexture != NULL)
  289.                         if ((**(**myAppData).fTexture).fMovie != NULL)
  290.                             QTVRUtils_StopMovieSound((**(**myAppData).fTexture).fMovie);
  291.                     break;
  292.                 
  293.                 case iTest5:    // start embedded movie sound                        
  294.                     if ((**myAppData).fTexture != NULL)
  295.                         if ((**(**myAppData).fTexture).fMovie != NULL)
  296.                             QTVRUtils_PlayMovieSound((**(**myAppData).fTexture).fMovie);
  297.                     break;
  298.                     
  299.                 case iTest6:
  300.                     VR3DObjects_FadeObjects(myAppData, true);
  301.                     break;
  302.                     
  303.                 case iTest7:
  304.                     VR3DObjects_FadeObjects(myAppData, false);
  305.                     break;
  306.             }
  307.             break;
  308.         
  309.         case mObjects:    // select a new 3D object    
  310.         
  311.             // dispose of the existing 3D object
  312.             if ((**myAppData).fModel != NULL)
  313.                 Q3Object_Dispose((**myAppData).fModel);
  314.                 
  315.             switch(theMenuItem) {
  316.                 case iBox:
  317.                     (**myAppData).fModel = VR3DObjects_CreateModel(kQ3GeometryTypeBox);
  318.                     break;
  319.                 
  320.                 case iCone:
  321.                     (**myAppData).fModel = VR3DObjects_CreateModel(kQ3GeometryTypeCone);
  322.                     break;
  323.                 
  324.                 case iCylinder:
  325.                     (**myAppData).fModel = VR3DObjects_CreateModel(kQ3GeometryTypeCylinder);
  326.                     break;
  327.                 
  328.                 case iEllipsoid:
  329.                     (**myAppData).fModel = VR3DObjects_CreateModel(kQ3GeometryTypeEllipsoid);
  330.                     break;
  331.                 
  332.                 case iTorus:
  333.                     (**myAppData).fModel = VR3DObjects_CreateModel(kQ3GeometryTypeTorus);
  334.                     break;
  335.                     
  336.                 case iPolyhedron:
  337.                     (**myAppData).fModel = VR3DObjects_CreateModel(kQ3GeometryTypePolyhedron);
  338.                     break;
  339.                     
  340.                 case i3DMFFile:
  341.                     VR3DObjects_GetModelFromFile();
  342.                     break;
  343.                     
  344.                 default:
  345.                     break;
  346.             }
  347.             
  348.             // restore any existing texture
  349.             if ((**myAppData).fTexture != NULL)
  350.                 VR3DTexture_AddToGroup((**myAppData).fTexture, (**myAppData).fModel);
  351.             
  352.             // set some default 3D object properties
  353.             if (theMenuItem != i3DMFFile)
  354.                 Q3Point3D_Set(&(**myAppData).fGroupCenter, 0.0, 0.0, -k3DObjectDistance);
  355.             (**myAppData).fObjectIndex = theMenuItem;
  356.             (**myAppData).fMustRender = true;
  357.             break;
  358.     }
  359. }
  360.  
  361.  
  362. //////////
  363. //
  364. // AdjustApplicationMenus
  365. // Adjust state of items in the application's menus.
  366. //
  367. //////////
  368.  
  369. void AdjustApplicationMenus (void)
  370. {
  371.     WindowRef             myWindow = NULL;
  372.     MovieController     myMC = NULL;
  373.     
  374.     myMC = GetMCFromFrontWindow();
  375.     if (myMC != NULL) {
  376.         EnableItem(GetMHandle(mTesting), iTest1);
  377.         EnableItem(GetMHandle(mTesting), iTest2);
  378.         EnableItem(GetMHandle(mTesting), iTest3);
  379.         EnableItem(GetMHandle(mTesting), iTest4);
  380.         EnableItem(GetMHandle(mTesting), iTest5);
  381.         EnableItem(GetMHandle(mTesting), iTest6);
  382.         EnableItem(GetMHandle(mTesting), iTest7);
  383.         EnableItem(GetMHandle(mObjects), iBox);
  384.         EnableItem(GetMHandle(mObjects), iCone);
  385.         EnableItem(GetMHandle(mObjects), iCylinder);
  386.         EnableItem(GetMHandle(mObjects), iEllipsoid);
  387.         EnableItem(GetMHandle(mObjects), iTorus);
  388.         EnableItem(GetMHandle(mObjects), iPolyhedron);
  389.         EnableItem(GetMHandle(mObjects), i3DMFFile);
  390.     } else {
  391.         DisableItem(GetMHandle(mTesting), iTest1);
  392.         DisableItem(GetMHandle(mTesting), iTest2);
  393.         DisableItem(GetMHandle(mTesting), iTest3);
  394.         DisableItem(GetMHandle(mTesting), iTest4);
  395.         DisableItem(GetMHandle(mTesting), iTest5);
  396.         DisableItem(GetMHandle(mTesting), iTest6);
  397.         DisableItem(GetMHandle(mTesting), iTest7);
  398.         DisableItem(GetMHandle(mObjects), iBox);
  399.         DisableItem(GetMHandle(mObjects), iCone);
  400.         DisableItem(GetMHandle(mObjects), iCylinder);
  401.         DisableItem(GetMHandle(mObjects), iEllipsoid);
  402.         DisableItem(GetMHandle(mObjects), iTorus);
  403.         DisableItem(GetMHandle(mObjects), iPolyhedron);
  404.         DisableItem(GetMHandle(mObjects), i3DMFFile);
  405.     }
  406.     
  407.     DisableItem(GetMHandle(mFile), iNew);        // we don't allow creating new VR files here...
  408.     
  409.     // if QuickDraw 3D isn't available, don't allow reading models or embedding movies
  410.     if (!gHasQuickDraw3D) {
  411.         DisableItem(GetMHandle(mTesting), iTest3);
  412.         DisableItem(GetMHandle(mTesting), iTest4);
  413.         DisableItem(GetMHandle(mTesting), iTest5);
  414.         DisableItem(GetMHandle(mObjects), iBox);
  415.         DisableItem(GetMHandle(mObjects), iCone);
  416.         DisableItem(GetMHandle(mObjects), iCylinder);
  417.         DisableItem(GetMHandle(mObjects), iEllipsoid);
  418.         DisableItem(GetMHandle(mObjects), iTorus);
  419.         DisableItem(GetMHandle(mObjects), iPolyhedron);
  420.         DisableItem(GetMHandle(mObjects), i3DMFFile);
  421.     }
  422.     
  423.     // if the front window has no embedded movie or the movie has no sound track,
  424.     // disable sound-adjusting menu items;
  425.     // if the front window has a predefined 3D object, 
  426.     // check appropriate item in Objects menu
  427.     {
  428.         ApplicationDataHdl    myAppData;
  429.         short                myIndex;
  430.         
  431.         // assume there's no movie or no sound
  432.         DisableItem(GetMHandle(mTesting), iTest4);
  433.         DisableItem(GetMHandle(mTesting), iTest5);
  434.         
  435.         myAppData = (ApplicationDataHdl)GetAppDataFromFrontWindow();
  436.         if (myAppData != NULL) {
  437.         
  438.             // handle sound-related items
  439.             if (((**myAppData).fTexture != NULL) && (**myAppData).fQTMovieHasSound) {
  440.                 EnableItem(GetMHandle(mTesting), iTest4);
  441.                 EnableItem(GetMHandle(mTesting), iTest5);
  442.             }
  443.             
  444.             // handle checkmarks in Objects menu
  445.             for (myIndex = iBox; myIndex <= i3DMFFile; myIndex++) {
  446.                 CheckItem(GetMHandle(mObjects), myIndex, (myIndex == (**myAppData).fObjectIndex));
  447.             }
  448.         }
  449.         
  450.     }
  451.     
  452. }
  453.  
  454.  
  455. //////////
  456. //
  457. // AddControllerFunctionality
  458. // Configure the movie controller.
  459. //
  460. //////////
  461.  
  462. void AddControllerFunctionality (MovieController theMC)
  463. {
  464.     long            myControllerFlags;
  465.     
  466.     // CLUT table use    
  467.     MCDoAction(theMC, mcActionGetFlags, &myControllerFlags);
  468.     MCDoAction(theMC, mcActionSetFlags, (void *)(myControllerFlags | mcFlagsUseWindowPalette));
  469.  
  470.     // enable keyboard event handling    
  471.     MCDoAction(theMC, mcActionSetKeysEnabled, (void *)true);
  472.     
  473.     // disable drag support
  474.     MCDoAction(theMC, mcActionSetDragEnabled, (void *)false);
  475. }
  476.  
  477.  
  478. //////////
  479. //
  480. // GetQTVRInstanceFromFrontWindow
  481. // Get the QTVRInstance associated with the front window.
  482. //
  483. //////////
  484.  
  485. QTVRInstance GetQTVRInstanceFromFrontWindow (void)
  486. {
  487.     QTVRInstance         myInstance = NULL;
  488.     WindowRef             myWindow = NULL;
  489.     WindowObject        myWindowObject = NULL;
  490.  
  491.     myWindow = FrontWindow();
  492.     if (myWindow == NULL)
  493.         return(NULL);
  494.  
  495.     if (!IsAppWindow(myWindow))
  496.         return(NULL);
  497.             
  498.     myWindowObject = (WindowObject)GetWRefCon(myWindow);
  499.     if (myWindowObject == NULL)
  500.         return(NULL);
  501.         
  502.     HLockHi((Handle)myWindowObject);
  503.  
  504.     // make sure this is a window object
  505.     if (!IsWindowObjectOurs(myWindowObject))
  506.         return(NULL);
  507.         
  508.     myInstance = (**myWindowObject).fInstance;
  509.     
  510.     HUnlock((Handle)myWindowObject);
  511.     
  512.     return(myInstance);
  513. }
  514.  
  515.  
  516. //////////
  517. //
  518. // InitApplicationWindowObject
  519. // Do any application-specific initialization of the window object.
  520. //
  521. //////////
  522.  
  523. void InitApplicationWindowObject (WindowObject theWindowObject)
  524. {
  525.     Track                myQTVRTrack = NULL;
  526.     OSErr                myErr = noErr;
  527.     Movie                myMovie = NULL;
  528.     MovieController        myMC = NULL;
  529.     QTVRInstance        myInstance = NULL;
  530.  
  531.     if (theWindowObject == NULL)
  532.         return;
  533.  
  534.     // find the QTVR track
  535.     myMovie = (**theWindowObject).fMovie;
  536.     myMC = (**theWindowObject).fController;
  537.     myQTVRTrack = QTVRGetQTVRTrack(myMovie, 1);
  538.     
  539.     myErr = QTVRGetQTVRInstance(&myInstance, myQTVRTrack, myMC);
  540.     (**theWindowObject).fInstance = myInstance;
  541.  
  542.     // do any app-specific window configuration
  543.     if (myInstance != NULL) {
  544.     
  545.         // set unit to radians
  546.         myErr = QTVRSetAngularUnits(myInstance, kQTVRRadians);
  547.  
  548.         // do any 3D-specific configuration
  549.         if (gHasQuickDraw3D) {
  550.             ApplicationDataHdl    myAppData;
  551.         
  552.             // do QuickDraw 3D window configuration
  553.             myAppData = VR3DObjects_InitWindowData(theWindowObject);
  554.             (**theWindowObject).fAppData = (Handle)myAppData;
  555.                     
  556.             // install an intercept procedure to handle signal a changed pan/tilt/zoom for 3D overlay
  557.             VR3DObjects_InstallInterceptRoutine(myInstance, theWindowObject);
  558.             
  559.             // for panoramic nodes,
  560.             // install a prescreen buffer imaging complete procedure to image the 3D overlay
  561.             if (QTVRGetNodeType(myInstance, kQTVRCurrentNode) == kQTVRPanoramaType)
  562.                 VR3DObjects_InstallPrescreenRoutine(myInstance, theWindowObject);
  563.  
  564.             // initialize QD3D camera's aspect ratio                                 
  565.             VR3DObjects_SetCameraAspectRatio(theWindowObject);                                 
  566.  
  567.             // initialize QD3D camera's point-of-interest and FOV
  568.             VR3DObjects_SetCamera(theWindowObject);
  569.             
  570.             if (myAppData != NULL)
  571.                 (**myAppData).fMustRender = true;
  572.             QTVRUpdate(myInstance, kQTVRCurrentMode);
  573.         }
  574.     }
  575. }
  576.  
  577.  
  578. //////////
  579. //
  580. // RemoveApplicationWindowObject
  581. // Do any application-specific clean-up of the window object.
  582. //
  583. //////////
  584.  
  585. void RemoveApplicationWindowObject (WindowObject theWindowObject)
  586. {
  587.     OSErr                myErr = noErr;
  588.     QTVRInstance        myInstance = NULL;
  589.     ApplicationDataHdl    myAppData;
  590.         
  591.     // do some preliminary parameter checking
  592.     if (theWindowObject == NULL)
  593.         return;
  594.         
  595.     myAppData = (ApplicationDataHdl)GetAppDataFromWindowObject(theWindowObject);
  596.         
  597.     // QuickTime VR clean-up
  598.     myInstance = (**theWindowObject).fInstance;
  599.     if (myInstance != NULL) {
  600.     
  601.     }
  602.     
  603.     // QuickDraw 3D clean-up
  604.     if (gHasQuickDraw3D) {
  605.         if (myAppData != NULL) {
  606.             if ((**myAppData).fView)
  607.                 Q3Object_Dispose((**myAppData).fView);
  608.             if ((**myAppData).fModel)
  609.                 Q3Object_Dispose((**myAppData).fModel);
  610.             if ((**myAppData).fInterpolation)
  611.                 Q3Object_Dispose((**myAppData).fInterpolation);
  612.             if ((**myAppData).fBackFacing)
  613.                 Q3Object_Dispose((**myAppData).fBackFacing);
  614.             if ((**myAppData).fFillStyle)
  615.                 Q3Object_Dispose((**myAppData).fFillStyle);
  616.             VR3DTexture_Delete((**myAppData).fTexture);
  617.             
  618.             // dispose of GWorlds used by this window object
  619.             DisposeGWorld((**myAppData).fGWorld);
  620.         }
  621.     }
  622.     
  623.     // application clean-up
  624.     if (myAppData != NULL)
  625.         DisposeHandle((Handle)myAppData);
  626.  
  627.     // DoDestroyMovieWindow in MacFramework.c releases the window object itself
  628. }
  629.  
  630.  
  631. //////////
  632. //
  633. // ApplicationMCActionFilterProc 
  634. // Intercept some mc actions for the QuickTime VR movie controller.
  635. //
  636. //////////
  637.  
  638. pascal Boolean ApplicationMCActionFilterProc (MovieController theMC, short theAction, void *theParams, WindowRef theWindow)
  639. {
  640.     Boolean                isHandled = false;
  641.     WindowObject        myWindowObject;
  642.     ApplicationDataHdl    myAppData;
  643.  
  644.     // get the window object associated with the specified window
  645.     myWindowObject = (WindowObject)GetWRefCon(theWindow);
  646.     
  647.     // do some preliminary parameter checking
  648.     if (myWindowObject == NULL)
  649.         return(isHandled);
  650.         
  651.     myAppData = (ApplicationDataHdl)GetAppDataFromWindowObject(myWindowObject);
  652.                 
  653.     switch (theAction) {
  654.     
  655.         // handle window resizing
  656.         case mcActionControllerSizeChanged: {
  657.             Rect                myRect;
  658.  
  659.             // get the new boundary rectangle of the QTVR controller and set window size
  660.             MCGetControllerBoundsRect(theMC, &myRect);
  661.             SizeWindow((WindowPtr)theWindow, myRect.right - myRect.left, myRect.bottom - myRect.top, true);
  662.                                              
  663.             // because the window size has changed, 
  664.             // we need to recalculate QD3D camera's aspect ratio and resize QD3D draw context
  665.             if (myAppData != NULL) {
  666.                 VR3DObjects_SetCameraAspectRatio(myWindowObject);                                 
  667.                 VR3DObjects_UpdateDrawContext(myWindowObject);                                 
  668.                 (**myAppData).fMustRender = true;
  669.             }
  670.             break;
  671.         }
  672.         
  673.         // look for any sound-related actions and route them to the embedded QuickTime movie,
  674.         // not to the QTVR controller
  675.         case mcActionGetVolume:
  676.         case mcActionSetVolume: {
  677.             short                myVolume, *myVolumePtr;
  678.             Movie                myMovie;
  679.  
  680.             if (myAppData == NULL)
  681.                 break;
  682.             
  683.             if (!(**myAppData).fQTMovieHasSound)
  684.                 break;
  685.             
  686.             if ((**myAppData).fTexture != NULL) {
  687.                 if ((**(**myAppData).fTexture).fMovie != NULL) {
  688.                 
  689.                     myMovie = (**(**myAppData).fTexture).fMovie;
  690.  
  691.                     if (theAction == mcActionGetVolume) {
  692.                         myVolume = GetMovieVolume(myMovie);
  693.                         theParams = &myVolume;
  694.                     }
  695.                         
  696.                     if (theAction == mcActionSetVolume) {
  697.                         myVolumePtr = (short *)theParams;
  698.                         myVolume = *myVolumePtr;
  699.                         SetMovieVolume(myMovie, myVolume);
  700.                     }
  701.                     
  702.                     isHandled = true;
  703.                 }
  704.             }
  705.                         
  706.             break;
  707.         }
  708.                 
  709.         default:
  710.             break;
  711.             
  712.     }    // switch(theAction)
  713.     
  714.     return(isHandled);    
  715. }
  716.